/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
    el: '#main',
    data: {
		checkDatas : [],		
		organCode: '',
        sysCode:'',  // 系统名称
        sysList: [],  // 系统名称列表
        productCode: '',  // 产品编码
        tipmsg: '',  // 提示框信息
        nowPage:1,
        rowNum:10,
        allPages:0,
        pagination: [],
        count: '', //总数
        startTime: '',  // 开始日期
        endTime: '',  // 结束日期
        pageNum: '', // 跳转的页码
    },
    created() {
        this.sysname()
    },
    methods: {
        // 获取系统名称的value值
        sysValue(e){
            this.sysCode = e.target.value
        },
        // 系统名称列表初始接口
        sysname() {
            axios({
				method: 'post',
				url: App.envUrl.backtrackUrl + 'quality/querySysMaintain',
                // url: 'http://192.168.1.81:8080/slxt-web/quality/querySysMaintain',  // 文华本地
                data: {}
			})
			.then((data) => {
                this.sysList = data.data.data
                console.log('sys=',this.sysList)
                
			})
			.catch((err) => {});
        },

		 //分页
         selectPage(page){
            this.nowPage = page;
            this.search();
        },
        offsetPage(offset){
            this.nowPage = this.nowPage + offset;
            this.search();
        },
    	search:function(){
            var _this = this 
            _this.startTime =  $('#beginDay').val()
            _this.endTime = $('#endDay').val()        
			var data = {
				sysCode: _this.sysCode,
				productCode: _this.productCode,
				startTime:$('#beginDay').val(),
                endTime:$('#endDay').val(),
                nowPage: _this.nowPage,
                rowNum: _this.rowNum,
            };
			axios({
				method: 'post',
				url: App.envUrl.backtrackUrl + 'quality/queryAccountList',
				// url: 'http://192.168.1.81:8080/slxt-web/quality/queryAccountList',  // 文华本地
				data: data,
			})
			.then((data) => {
                console.log('res',data)
                // _this.count = data.data.pageCount.allCount
                var list = data.data.pageCount.datas
                console.log(list)
                if(list.length != 0) {
                    this.allPages = data.data.pageCount.allPages;
                    this.pagination = getPagination(this.nowPage,this.allPages);
                    list.forEach(item => {
                        if (item.dataState == '1') {
                            item.dataState = '开始录制'       
                        }else if(item.dataState == '2'){
                            item.dataState = '离开录制'
                        }else if(item.dataState == '3'){
                        	item.dataState = '已完成'
                        }
                    });
                }
                _this.checkDatas = list
			})
			.catch((err) => {});
    	},
        // 查询按钮
		check_c:function(){
			this.search();
		},
        //重置按钮
        check_r:function(){
            window.location.reload();
		},
		
    }
});

function rowNumChange(value) {
    vm.queryData.rowNum = value;
    vm.queryData.nowPage = 1;
    vm.search();
}
